package com.car.util;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.car.application.LocalApplication;

public class VersionUtil {
	public static String getAppVersionName() {
		String versionName = "";

		try {
			PackageManager pm = LocalApplication.getInstance()
					.getPackageManager();
			PackageInfo pi = pm.getPackageInfo(LocalApplication.getInstance()
					.getPackageName(), 0);
			versionName = pi.versionName;
			if (versionName == null || versionName.length() <= 0) {
				return "";
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

		return versionName;
	}

	public static Integer getAppVersionCode() {
		int versionCode = 0;

		try {
			PackageManager pm = LocalApplication.getInstance()
					.getPackageManager();
			PackageInfo pi = pm.getPackageInfo(LocalApplication.getInstance()
					.getPackageName(), 0);
			versionCode = pi.versionCode;
			return versionCode;
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return versionCode;
	}
}
